// 生产计划查询参数
export interface ProductionPlanQueryDto {
  pageIndex: number
  pageSize: number
  planNumber?: string
  planSubject?: string
  documentDateStart?: string
  documentDateEnd?: string
  status?: string
}

// 生产计划实体
export interface ProductionPlan {
  id: number
  planNumber: string
  planSubject: string
  documentDate: string
  salesOrderSubject: string
  projectName: string
  remarks: string
  status: string
  isBindSalesOrder: boolean
  creator: string
  createTime: string
  updator: string
  updateTime: string
}

// 生产计划分页响应
export interface ProductionPlanPageResult {
  totalCount: number
  totalPages: number
  pageIndex: number
  pageSize: number
  items: ProductionPlan[]
}

// 生产计划API响应
export interface ProductionPlanApiResult<T> {
  msg: string
  code: number
  data: T
}

// 状态枚举
export enum ProductionPlanStatus {
  DRAFT = 'draft',
  APPROVED = 'approved',
  EXECUTING = 'executing',
  COMPLETED = 'completed'
}

// 状态显示文本映射
export const STATUS_TEXT_MAP: Record<string, string> = {
  [ProductionPlanStatus.DRAFT]: '草稿',
  [ProductionPlanStatus.APPROVED]: '已审核',
  [ProductionPlanStatus.EXECUTING]: '执行中',
  [ProductionPlanStatus.COMPLETED]: '已完成'
}

// 状态类型映射（用于Element Plus标签颜色）
export const STATUS_TYPE_MAP: Record<string, string> = {
  [ProductionPlanStatus.DRAFT]: 'info',
  [ProductionPlanStatus.APPROVED]: 'success',
  [ProductionPlanStatus.EXECUTING]: 'warning',
  [ProductionPlanStatus.COMPLETED]: 'success'
}

// 新增生产计划相关类型
export interface ProductionItem {
  id?: number
  index?: number
  itemNumber: string
  itemName: string
  specificationModel: string
  unit: string
  itemCategory: string
  itemClassification: string
  brand: string
  quantity: number
  detailDate: string
  mainUnitQuantity: number
  remarks: string
}

export interface Attachment {
  fileName: string
  filePath: string
  fileSize: number
  fileType: string
  uploadDate?: string
}

export interface CreateProductionPlanDto {
  planNumber: string
  planSubject: string
  documentDate: string
  salesOrderId: number
  projectId: number
  remarks: string
  isBindSalesOrder: boolean
  productedItems: ProductionItem[]
  attachments: Attachment[]
  selectedItemIds: number[]
  selectedSalesOrderIds: number[]
}

// 物品查询相关类型
export interface ItemQueryDto {
  itemNumberOrNameOrModel: string
  itemCategory: string
  itemClassification: string
  inventoryStatus: string
  pageIndex: number
  pageSize: number
}

export interface Item {
  id: number
  itemNumber: string
  itemName: string
  specificationModel: string
  unit: string
  itemCategory: string
  itemClassification: string
  brand: string
  totalInventory: number
  purchaseUnitPrice: number
  salesUnitPrice: number
}

export interface ItemPageResult {
  totaCount: number
  totaPage: number
  pageData: Item[]
}

// 销售订单相关类型
export interface SalesOrderQueryDto {
  salesOrderNumberOrSubject: string
  customerName: string
  salesDateStart: string
  salesDateEnd: string
  purchaseStatus: string
  pageIndex: number
  pageSize: number
}

export interface SalesOrder {
  id: number
  salesOrderNumber: string
  salesOrderSubject: string
  customerName: string
  salesDate: string
  purchaseStatus: string
  itemSummary: string
  createTime: string
}

export interface SalesOrderPageResult {
  totaCount: number
  totaPage: number
  pageData: SalesOrder[]
}

// 销售订单物品相关类型
export interface SalesOrderItemQueryDto {
  salesOrderId: number
  itemNumberOrNameOrModel: string
  itemCategory: string
  itemClassification: string
  inventoryStatus: string
  pageIndex: number
  pageSize: number
}

export interface SalesOrderItem {
  id: number
  itemNumber: string
  itemName: string
  specificationModel: string
  unit: string
  itemCategory: string
  itemClassification: string
  brand: string
  totalInventory: number
  salesQuantity: number
}

export interface SalesOrderItemPageResult {
  totaCount: number
  totaPage: number
  pageData: SalesOrderItem[]
}

// 项目类型
export interface Project {
  id: number
  projectName: string
  projectCode: string
}

// 操作记录
export interface OperationLog {
  operationTime: string
  operator: string
  operationContent: string
}

// 生产计划详情
export interface ProductionPlanDetail {
  id: number
  planNumber: string
  planSubject: string
  documentDate: string
  salesOrderId: number
  projectId: number
  remarks: string
  status: string
  isBindSalesOrder: boolean
  creator: string
  createTime: string
  updator: string
  updateTime: string
  productedItems: ProductionItem[]
  attachments: Attachment[]
  operationLogs: OperationLog[]
}

// 生产计划详情API响应
export interface ProductionPlanDetailApiResult {
  msg: string
  code: number
  data: ProductionPlanDetail
} 